﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Stie_TypeSelect : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public void BindData(int stId)
    {
        CMSModel.CMSEntities dal = DAL.DBManager.GetCmsEmtity();
        int tid = int.Parse(Pid);
        //bool isChild = false;

        int childCount = dal.SiteType.Where(x => x.pid == tid).Count();
        if (childCount != 0)
        {
            cbxlstCid.DataSource = dal.SiteType.Where(x => x.pid == tid);
            cbxlstCid.DataValueField = "stid";
            cbxlstCid.DataTextField = "name";
            cbxlstCid.DataBind();
        }
        else
        {
            cbxlstCid.DataSource = dal.SiteType.Where(x => x.stid == tid);
            cbxlstCid.DataValueField = "stid";
            cbxlstCid.DataTextField = "name";
            cbxlstCid.DataBind();
        }
        var pType = dal.SiteType.Where(x => x.stid == tid).First();
        lblPType.Text = pType.name;
    }

    public string Pid
    {
        get
        {
            return ViewState["pid"].ToString();
        }
        set
        {
            ViewState["pid"] = value;
        }
    }
}